package com.example.administrator.zhjt.bean;

import android.content.ContentValues;
import android.database.Cursor;

import com.example.administrator.zhjt.db.BillDB;

import java.util.Objects;

/**
 * Created by Administrator on 2017/5/16 0016.
 */

public class Bill {

    private int id;
    private int carId;
    private int money;
    private String user;
    private long createAt;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getCarId() {
        return carId;
    }

    public void setCarId(int carId) {
        this.carId = carId;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public long getCreateAt() {
        return createAt;
    }

    public void setCreateAt(long createAt) {
        this.createAt = createAt;
    }

    public Bill formCursor(Cursor cursor){
        Bill bill=null;
        if (cursor!=null){
            bill=new Bill();
            bill.setId(cursor.getInt(cursor.getColumnIndex(BillDB.KEY_ID)));
            bill.setCarId(cursor.getInt(cursor.getColumnIndex(BillDB.KEY_CARID)));
            bill.setMoney(cursor.getInt(cursor.getColumnIndex(BillDB.KEY_MONEY)));
            bill.setUser(cursor.getString(cursor.getColumnIndex(BillDB.KEY_USER)));
            bill.setCreateAt(cursor.getLong(cursor.getColumnIndex(BillDB.KEY_TIME)));
        }
        return bill;
    }

    public ContentValues toContentValues(){
        ContentValues contentValues=new ContentValues();
        contentValues.put(BillDB.KEY_CARID,getId());
        contentValues.put(BillDB.KEY_CARID,getCarId());
        contentValues.put(BillDB.KEY_MONEY,getMoney());
        contentValues.put(BillDB.KEY_USER,getUser());
        contentValues.put(BillDB.KEY_TIME,System.currentTimeMillis());
        return contentValues;
    }

}
